package com.gavel.parser;

import com.gavel.utils.StringUtils;

public class NumberUtils {

    public static float toFloat(String text) {
        float res = 0.0f;
        if (StringUtils.isBlank(text)) {
            return res;
        }

        StringBuilder buf = new StringBuilder();

        for (char c : text.toCharArray()) {
            if ( Character.isDigit(c) || c == '.'  ) {
                buf.append(c);
            }
        }

        if ( buf.length() == 0 ) {
            return res;
        }

        try {
            res = Float.parseFloat(buf.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return res;
    }

    public static void main(String[] args) {
        System.out.println(toFloat("¥22,900.00"));
    }

}
